var t = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../DPagination")), e = getApp(), a = new t.default("rewardRecords"), n = e.getNetAddresss("plugin.commission-ranking.api.get-commission-ranking.bonus-log"), r = "";

Page({
    data: {
        rewardRecords: [],
        customSettings: {
            expectedEarningText: "本月预计收益"
        },
        calendarMonths: {
            1: "01",
            2: "02",
            3: "03",
            4: "04",
            5: "05",
            6: "06",
            7: "07",
            8: "08",
            9: "09",
            10: "10",
            11: "11",
            12: "12"
        },
        showCalendar: !1,
        currentSelectedYear: 2e3,
        currentSelectedMonth: 1,
        currentYear: 1,
        currentMonth: 1,
        isLastMonth: !0
    },
    onLoad: function(t) {
        wx.setNavigationBarTitle({
            title: "历史排行榜记录"
        }), this.setNowDate(), a.bind(this), this.dateChanged();
    },
    onPullDownRefresh: function() {
        a.clean(), this.loadRewardRecord();
    },
    onReachBottom: function() {
        this.loadRewardRecord();
    },
    onShareAppMessage: function() {},
    onShareTimeline: function() {},
    loadRewardRecord: function() {
        a.loading || a.finished || (wx.showLoading({
            title: "加载中",
            mask: !0
        }), a.loading = !0, e._getNetWork({
            url: n,
            data: {
                page: a.loadPage,
                time: r
            },
            success: function(t) {
                var e = t.data, n = e.data, r = e.result, i = e.msg;
                0 != r ? (n.data.length < a.limit && (a.finished = !0), a.limit != n.per_page && (a.limit = n.per_page), 
                a.push(n.data), a.loading = !1, wx.hideLoading(), wx.stopPullDownRefresh()) : wx.showToast({
                    title: i,
                    icon: "none"
                });
            }
        }));
    },
    setNowDate: function() {
        var t = new Date(), e = t.getFullYear(), a = t.getMonth() + 1;
        this.setData({
            currentSelectedYear: e,
            currentSelectedMonth: a,
            currentYear: e,
            currentMonth: a
        });
    },
    selectMonth: function(t) {
        var e = t.target.dataset;
        if (e.month) {
            var a = Number(e.month);
            this.data.currentSelectedYear == this.data.currentYear && a > this.data.currentMonth || (this.setData({
                currentSelectedMonth: Number(e.month),
                isLastMonth: a == this.data.currentMonth
            }), this.dateChanged());
        }
    },
    displayCalendar: function() {
        this.setData({
            showCalendar: !this.data.showCalendar
        });
    },
    switchToPreviousYear: function() {
        var t = this.data.currentSelectedYear, e = {};
        t - 1 != 0 && (e.currentSelectedYear = t - 1, this.setData(e), this.dateChanged());
    },
    switchToNextYear: function() {
        var t = Number(this.data.currentSelectedYear), e = Number(this.data.currentYear), a = {};
        if (!(e == t || t + 1 > e)) {
            if (a.currentSelectedYear = t + 1, t + 1 == e) {
                var n = this.data.currentSelectedMonth, r = Number(this.data.currentMonth);
                n > r && (a.currentSelectedMonth = r);
            }
            this.setData(a), this.dateChanged();
        }
    },
    dateChanged: function() {
        a.clean();
        var t = this.data.currentSelectedMonth;
        1 == String(t).length && (t = "0".concat(t)), this.data.currentYear == this.data.currentSelectedYear ? this.setData({
            isLastMonth: !0
        }) : this.data.isLastMonth && this.setData({
            isLastMonth: !1
        }), r = "".concat(this.data.currentSelectedYear, "-").concat(t), this.loadRewardRecord();
    }
});